package com.prs.moa.system.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.prs.moa.system.model.TreeModel;

@Component
public class SystemDAO {

	@Resource
	private HibernateTemplate hibernateTemplate;

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
	
	@SuppressWarnings("unchecked")
	public List<TreeModel> selectTreeByTreeId(final String treeId){
		StringBuffer sql = new StringBuffer();
		sql.append("from TreeModel where 1=1 ");
		sql.append("and treeid_ = '"+ treeId+"'");
		final String typeSql = new String(sql);
		List<TreeModel> list = (List<TreeModel>)this.hibernateTemplate.find(typeSql);
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<TreeModel> selectAll(){
		List<TreeModel> list = (List<TreeModel>)this.hibernateTemplate.find("from TreeModel where 1=1");
		return list;
	}
}
